# -*- coding: utf-8 -*-
'''
Created on 2012-1-27

@author: y
'''
from admin.models import Dept

class UserTrackerMiddleware(object):
    
    def process_request(self, request):
#        'print 'user.id=', request.user.id
        if request.user.is_authenticated():
            query_set = Dept.objects.filter(principal_auth_user=request.user)
            request.META['management_role'] = (query_set != None and len(query_set) > 0)
        else:
            request.META['management_role'] = False
#            print "request.META['management_role']=", request.META['management_role']

        